import React, { Component } from 'react'

import { commonFunc } from '../utils/common'

const actions = {
  clickfn() {
    console.log('我好像在哪见过你');
  },
  next(msg) {
    // console.log(msg);
    console.log('他想知道那是谁' + msg);
  },
  stop(e) {
    e.stopPropagation();
    e.preventDefault();
    console.log("阻止事件冒泡");
  }
}


export default class MyEvent extends Component {

  handleClick() {
    console.log('惊喜');
  }


  render() {
    return (
      <div>
        <h3 onClick={() => console.log('直接写')} style={{ color: 'darkblue' }}>
          React 事件绑定
        </h3>
        <h3 onClick={actions.clickfn}>
          React + Redux
        </h3>
        <h3 onClick={(e) => { actions.next(e) }}>
          默认有一个 event 参数
        </h3>
        <h3 onClick={() => { actions.next('，为何总沉默寡言') }}>
          要想传值 前面的 e 就不传
        </h3>
        <h3 onClick={actions.stop}>
          阻止事件冒泡
        </h3>
        <button onClick={() => {
          commonFunc.gotoWhere('/app/home')
          commonFunc.timeFormat()
        }}>
          点击进入主页
        </button>
        <br />
        <br />
        <button onClick={this.handleClick}>
          点我有惊喜
        </button>
      </div >
    )
  }
}
